package com.jason.designpattern.singleton;

/**
 * @description: 懒汉模式B
 * 优点：实现了懒加载；线程安全
 * 缺点：必须加锁 synchronized 才能保证单例，但加锁会影响效率，退化到串行
 * @author: jason.jia
 * @create: 2019-03-08 17:01
 **/
public class LazySingletonB {
    private static LazySingletonB instance;

    private LazySingletonB(){}

    public static synchronized LazySingletonB getInstance(){
        if(instance == null){
            instance = new LazySingletonB();
        }
        return instance;
    }
}
